package core;

import java.sql.SQLException;

import db.DBConnection;

public class CustomerManagement {

	public static void insertCustomer(DBConnection dbCon, String [] customer)
	{
		UtilityFunctions ut = new UtilityFunctions();
		String query = "INSERT INTO Cliente(CodiceFiscale, PartitaIva, Nome, Cognome, RagioneSociale, Indirizzo, Comune, Provincia, NumeroTelefono) " +
				"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);";
		try {
			ut.executeParametricUpdate(dbCon, query, customer);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public static void deleteCustomer(DBConnection dbCon, String customerCode)
	{
		UtilityFunctions ut = new UtilityFunctions();
		String query = "DELETE FROM Cliente " +
				"WHERE CodiceCliente = ?";
		try {
			ut.executeParametricUpdateSingleParameter(dbCon, query, customerCode);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public static void main(String[] args) {
		try {
			DBConnection dbCon = new DBConnection();
			String[] cust = {"czz", "", "michele", "nicolo", "ciao sas", "via piave", "zumpano", "cs", "0518060"};
			//CustomerManagement.insertCustomer(dbCon, cust);
			CustomerManagement.deleteCustomer(dbCon, "1");
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
}
